package com.chehongwei;

import com.chehongwei.aspect.*;
import com.chehongwei.ioc.ApplicationContext;
import com.chehongwei.ioc.MyApplicationContext;
import com.chehongwei.service.Eat;
import com.chehongwei.service.EatCookie;

public class AopTestMan {

    public static void main(
        String[] args)
        throws Exception {
        Pointcut pointcut =
            new MyPointCut("com.chehongwei.service.EatCookie", "eat");

        Advice advice = new MyAdvice();

        Aspect aspect = new Aspect(advice, pointcut);

        ApplicationContext applicationContext = new MyApplicationContext();

        applicationContext.setAspect(aspect);

        applicationContext.registerBean("eat", EatCookie.class);

        Eat eat = (Eat) applicationContext.getBean("eat");

        eat.eat("mike");
    }
}
